//
// Created by yanhai on 2021/5/2.
//

#include <iostream>
#include <thread>

void func(int i, const std::string &buf)
{
    std::cout << "buf=" << buf << std::endl;
}

void test()
{
    int mvar = 1;
    int &mvary = mvar;
    char mbuf[] = "this is test!";
    std::cout << "mbuf=" << mbuf << std::endl;
//    std::thread t(func, mvar, mbuf);    // mbuf隐式类型转换为string是在什么时候转换的？
    std::thread t(func, mvar, std::string(mbuf));
    t.detach();
}

int main(int argc, char **argv)
{
    test();
    std::this_thread::sleep_for(std::chrono::seconds(1));   // 为了让子线程得到执行
    return 0;
}
